<?php

namespace app\api\controller;

use app\api\service\ArticleService;
use app\api\validate\ArticleValidate;

class Article extends Base
{
    protected $middleware = ['NotFoundMiddleware'];

    /**
     * 获取文章分类
     * @needLogin FALSE
     * @method GET
     * @return void
     */
    public function getCategoryList()
    {
        list($code, $msg, $data) = ArticleService::getCategoryList($this->params);
        apiReturn($code, $msg, $data);
    }

    /**
     * 获取文章列表
     * @needLogin FALSE
     * @method GET
     * @return void
     */
    public function getArticleList()
    {
        if (($msg = ArticleValidate::getArticleList($this->params)) !== true) apiReturn(201, $msg);
        list($code, $msg, $data) = ArticleService::getArticleList($this->params);
        apiReturn($code, $msg, $data);
    }

    /**
     * 获取文章详情
     * @needLogin FALSE
     * @method GET
     * @return void
     */
    public function getArticleInfo()
    {
        if (($msg = ArticleValidate::getArticleInfo($this->params)) !== true) apiReturn(201, $msg);
        list($code, $msg, $data) = ArticleService::getArticleInfo($this->params);
        apiReturn($code, $msg, $data);
    }
}